
using System;
using System.Collections.Generic;
using BTKERP.Model;
using BTKERP.DAL.DataAccess;
using System;

namespace BTKERP.DAL
{
	#region WarehouseDAL
	public class WarehouseDAL : DBContext
	{
		public List<Warehouse> GetAll()
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_WarehousesSelectAll");
            return GetEntityList<Warehouse>(cmd);
        }

        public Warehouse GetById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_WarehouseSelect");
            cmd.AddParameter("@Id", id);
            return GetSingleEntity<Warehouse>(cmd);
        }

		public List<Warehouse> GetByDynamicSQL(string sqlCondition)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_WarehouseSelectDynamic");
            cmd.AddParameter("@SQL", sqlCondition);
            return GetEntityList<Warehouse>(cmd);
        } 
		
        public bool DeleteById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_WarehouseDelete");
            cmd.AddParameter("@Id", id);
            return ExecuteCommand(cmd);
        }

        public Warehouse Add(string paramName, string paramDescriptoin, bool paramIsCentral, string paramAddress1, string paramAddress2,
                                    string paramAddress3, string paramPostCode, string paramTel, string paramFax, string paramContactPerson,
                                    Guid paramCoutryId, Guid paramCityId, string paramCreatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_WarehouseInsert");
            cmd.AddParameter("@Name", paramName);
            cmd.AddParameter("@Descriptoin", paramDescriptoin);
            cmd.AddParameter("@IsCentral", paramIsCentral);
            cmd.AddParameter("@Address1", paramAddress1);
            cmd.AddParameter("@Address2", paramAddress2);
            cmd.AddParameter("@Address3", paramAddress3);
            cmd.AddParameter("@PostCode", paramPostCode);
            cmd.AddParameter("@Tel", paramTel);
            cmd.AddParameter("@Fax", paramFax);
            cmd.AddParameter("@ContactPerson", paramContactPerson);
            cmd.AddParameter("@CoutryId", paramCoutryId);
            cmd.AddParameter("@CityId", paramCityId);
            cmd.AddParameter("@CreatedBy", paramCreatedBy);
            return GetSingleEntity<Warehouse>(cmd);
        }

        public Warehouse UpdateById(Guid paramId, string paramName, string paramDescriptoin, bool paramIsCentral, string paramAddress1, string paramAddress2,
                                    string paramAddress3, string paramPostCode, string paramTel, string paramFax, string paramContactPerson,
                                    Guid paramCoutryId, Guid paramCityId, string paramUpdatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_WarehouseUpdate");
			cmd.AddParameter("@Id", paramId);
			cmd.AddParameter("@Name", paramName);
			cmd.AddParameter("@Descriptoin", paramDescriptoin);
            cmd.AddParameter("@IsCentral", paramIsCentral);
			cmd.AddParameter("@Address1", paramAddress1);
			cmd.AddParameter("@Address2", paramAddress2);
			cmd.AddParameter("@Address3", paramAddress3);
			cmd.AddParameter("@PostCode", paramPostCode);
			cmd.AddParameter("@Tel", paramTel);
			cmd.AddParameter("@Fax", paramFax);
			cmd.AddParameter("@ContactPerson", paramContactPerson);
			cmd.AddParameter("@CoutryId", paramCoutryId);
			cmd.AddParameter("@CityId", paramCityId);
			cmd.AddParameter("@UpdatedBy", paramUpdatedBy);
            return GetSingleEntity<Warehouse>(cmd);
        }


        public string GetwarehouseByDOId(System.Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("GetWarehouseById");
            cmd.AddParameter("@DOId", id);
            return GetSingleValue(cmd);
        }
    }
	#endregion
}
